// pages/liuyan/liuyan.js
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
      content:"",
      cid:"",
      lyc:""
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      console.log(options.id)
      var cid = options.id;
      var that = this;
      that.setData({
          cid:cid
      })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
      this.getslide();
  },
  getslide:function(){
      var that = this
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/Articlelittle/maseage/',
          data: {
              id: that.data.cid,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'GET',
          header: {
              'content-type': 'application/json'
          },
          success: function (res) {
              that.setData({
                  lyc: res.data.datas
              })
          }
      })
  },
  formBindsubmit: function (e) {
      var that = this;
      var shuruValue = e.detail.value.shuru;
      wx.request({
          url: 'https://www.mayizhihuan.com/Home/Articlelittle/maseage/',
          data: {
              content: e.detail.value.shuru,
              article_id: that.data.cid,
              PHPSESSID: wx.getStorageSync('sid')
          },
          method: 'POST',
          header: {
              'content-type': 'application/x-www-form-urlencoded'
          },
          success: function (res) {
              if (res.data) {
                  wx.showToast({
                      title: '提交成功',
                      icon: 'success',
                      duration: 2000
                  })
                  setTimeout(function () {
                      wx.redirectTo({
                          url: '../details/details?id=' + that.data.cid
                      })
                  }, 1000);
              }
          }
      })
  },
  /**
  * 用户点击右上角分享
  */
  onShareAppMessage: function () {

  }
})